package hello;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");


        UserServiceImpl user = (UserServiceImpl) context.getBean("user");
       // UserServiceImpl user2 =  context.getBean("user2",UserServiceImpl.class);
        UserServiceImpl user2 =  context.getBean("a",UserServiceImpl.class);
        UserServiceImpl user3 =  context.getBean("b",UserServiceImpl.class);
        UserServiceImpl user4 =  context.getBean("c",UserServiceImpl.class);

        user.m();
        user2.m();
        user3.m();
        user4.m();


        UserServiceImpl user5 =  context.getBean("d",UserServiceImpl.class);
        user5.m();
// 关闭容器
        ((ConfigurableApplicationContext)context).close();
    }
}
